package com.htsk.city.services.core.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.htsk.city.services.core.utils.InstantToMillisSerializer;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.Instant;

@Getter
@Setter
@Entity
@Table(name = "order_item")
public class OrderItem {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "item_id", nullable = false)
    private Long id;

    @NotNull
    @Column(name = "order_id", nullable = false)
    private Long orderId;

    @Size(max = 32)
    @NotNull
    @Column(name = "order_no", nullable = false, length = 32)
    private String orderNo;

    @Column(name = "product_id", nullable = false)
    private Long productId;

    @Size(max = 100)
    @Column(name = "product_name", nullable = false, length = 100)
    private String productName;

    @Size(max = 255)
    @Column(name = "product_image")
    private String productImage;

    @Column(name = "sku_id")
    private Long skuId;

    @Size(max = 50)
    @Column(name = "sku_code", length = 50)
    private String skuCode;

    @Size(max = 255)
    @Column(name = "sku_attrs")
    private String skuAttrs;

    @NotNull
    @Column(name = "price", nullable = false, precision = 10, scale = 2)
    private BigDecimal price;

    @NotNull
    @Column(name = "quantity", nullable = false)
    private Integer quantity;

    @NotNull
    @Column(name = "subtotal", nullable = false, precision = 10, scale = 2)
    private BigDecimal subtotal;

    @Column(name = "refund_status")
    private Byte refundStatus;

    @Column(name = "refund_amount", precision = 10, scale = 2)
    private BigDecimal refundAmount;

    @Column(name = "refund_time")
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant refundTime;

    @Size(max = 255)
    @Column(name = "refund_reason")
    private String refundReason;

    @NotNull
    @Column(name = "create_time", nullable = false)
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant createTime;

    @NotNull
    @Column(name = "update_time", nullable = false)
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant updateTime;
    /**
     * `technician_id` int(11) NULL COMMENT '师傅id' ,
     * `technician_name` varchar(255) NULL COMMENT '师傅名称' ,
     * `mobile` varchar(20) NULL COMMENT '师傅手机号' ,
     * `appointment_time` datetime NULL COMMENT '预约时间' ,
     * `service_sub_category_id` int(11) NULL COMMENT '服务子类型ID' ,
     * `service_sub_category_name` varchar(255) NULL COMMENT '服务子类型名称' ,
     * `user_latitude` decimal(11,8) NULL COMMENT '服务地址-纬度' ,
     * `user_longitude` decimal(11,8) NULL COMMENT '服务地址-经度' ,
     * `address` varchar(255) NULL COMMENT '服务地址' ,
     * `description` varchar(511) NULL COMMENT '服务描述' ;
     */
    @Column(name = "technician_id")
    private Long technicianId;
    @Column(name = "technician_name")
    private String technicianName;
    @Column(name = "technician_mobile")
    private String technicianMobile;
    @Column(name = "appointment_time")
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant appointmentTime;
    @Column(name = "service_sub_category_id")
    private Long serviceSubCategoryId;
    @Column(name = "service_sub_category_name")
    private String serviceSubCategoryName;
    @Column(name = "user_lat")
    private BigDecimal userLat;
    @Column(name = "user_lng")
    private BigDecimal userLng;
    @Column(name = "address")
    private String address;
    @Column(name = "description")
    private String description;


}